home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / lang / HeliOS3.lha / helios_demo_disk3 / source / DualPFScroll.src < prev    next >
Encoding:
Text File  |  1995-11-11  |  23.7 KB  |  771 lines

  1.   \ ***********************************************************
  2.   \
  3.   \      PARALLAX SCROLLING DUAL PLAYFIELD WITH TEXT DEMO
  4.   \
  5.   \ ***********************************************************
  6.   \
  7.   \ This code demonstrates how to create a display with multiple
  8.   \ dual playfield slices and variable speed parallax scrolling.
  9.   \
  10.   \ This code builds upon the following Demos:
  11.   \
  12.   \ Demo1_SinglePF.src
  13.   \ Demo2_SinglePFCopper.src
  14.   \
  15.   \ ***********************************************************
  16.  
  17.  
  18.  
  19.   \ ***********************************************************
  20.   \ Re-initialise HeliOS dictionary to standard CORE vocabulary
  21.   \ ***********************************************************
  22.  
  23.   \ This should always be used at the start of any program which
  24.   \ is to be repeatedly recompiled.
  25.  
  26.   FORGET **CORE**
  27.  
  28.   \ *************************
  29.   \ Load include symbol files
  30.   \ *************************
  31.   \
  32.   \ These "include files" are pre-compiled (for speed) versions of the
  33.   \ Amiga includes and the Helios system includes.
  34.   \
  35.   \ Uncomment the lines below for standalone compilation, but otherwise
  36.   \ it is better to set these include files from the Helios Forth menus
  37.  
  38.   AMIGAINCLUDE HeliOS:HeliOS_AmigaInclude
  39.   USERINCLUDE  HeliOS:HeliOS_UserInclude
  40.  
  41.   \ ****************************************
  42.   \ Create display imagery file name strings
  43.   \ ****************************************
  44.  
  45.   \ These files are ordinary IFF's (and may be "PowerPacked" if required)
  46.   \
  47.   \ The pictures here will be loaded into each of the display BitMaps.
  48.   \
  49.  
  50.   $CONSTANTL Slice1APic $Helios:Source/Data/Pic1A$
  51.   $CONSTANTL Slice1BPic $Helios:Source/Data/Pic1B$
  52.   $CONSTANTL Slice2APic $Helios:Source/Data/Pic2A$
  53.   $CONSTANTL Slice2BPic $Helios:Source/Data/Pic2B$
  54.   $CONSTANTL Slice3Pic  $Helios:Source/Data/Pic3$
  55.  
  56.   \ **************************************
  57.   \ Create display configuration constants
  58.   \ **************************************
  59.   \
  60.   \ Collect all "display-specific" parameters here and generate "named"
  61.   \ constants which make references easier than using numeric values.
  62.   \
  63.   \ Collecting these together here makes it easier to adjust things at any
  64.   \ time without having to search source code to replace values individually.
  65.   \
  66.  
  67.  
  68.   256                      CONSTANT DisplayHeight      \ Full PAL display
  69.   44                       CONSTANT DisplayTopLine     \ Display start
  70.  
  71.  \ The top slice is a scrolling display area with two 8-colour playfields
  72.  \
  73.  \ A-slice = foreground playfield and B-slice = background playfield
  74.  \
  75.  \ The B-slice has extra-wide horizontal raster size (640 pixels) to allow
  76.  \ for horizontal scrolling, with an additional 320 pixels width to allow
  77.  \ for horizontal smooth wrapping.
  78.  \
  79.  \ The A-slice does not scroll.
  80.  \
  81.  
  82.   320                      CONSTANT Slice1Width        \ Lores width
  83.   30                       CONSTANT Slice1Height       \ Top slice height
  84.   30                       CONSTANT Slice1RasterHeight \ Raster=sliceheight
  85.   WORDINCLUDE
  86.   V_DUALPF                 CONSTANT Slice1Mode         \ Top slice screenmode
  87.   LONGINCLUDE
  88.  
  89.   320                      CONSTANT Slice1ARasterWidth \ Raster=screenwidth
  90.   3                        CONSTANT Slice1APlanes      \ A-slice bitplanes
  91.   2 Slice1APlanes 1- LSL   CONSTANT Slice1AColours     \ A-slice colours
  92.  
  93.   640 320 +                CONSTANT Slice1BRasterWidth \ Scroll plane width
  94.   3                        CONSTANT Slice1BPlanes      \ B-slice bitplanes
  95.  
  96.   \ The calculation below takes the number of bitplanes and calculates
  97.   \ how many colours this represents.
  98.   \
  99.   \ One bitplane gives two colours.
  100.   \
  101.   \ Each additional bitplane multiplies the number of colours by two.
  102.   \
  103.   \ Performing a single LSL operation on any number multipies by 2, so we
  104.   \ have a quick method of multiplying by two for our colour calculation.
  105.   \
  106.   \ In this case, we need "2 to the power 3", which is 2*2*2=8.
  107.   \
  108.   \ e.g.                              2*2*2
  109.   \                                   ^ ^ ^
  110.   \                                   Total number of planes = 3
  111.   \
  112.   \
  113.   \ So, we take the first value two
  114.   \
  115.   \ e.g.                              2*2*2
  116.   \                                   ^
  117.   \                                  Initial start value of 2
  118.   \
  119.   \ and we now need to multiply it by two "the_number_of_planes minus_one"
  120.   \ more times.
  121.   \
  122.   \ e.g.                              2*2*2
  123.   \                                     ^ ^
  124.   \                                     Total planes minus one
  125.   \
  126.   \
  127.   \ So, Number of colours = 2 operated on by LSL NumberOfPlanes-1 times.
  128.   \
  129.  
  130.   2 Slice1BPlanes 1- LSL   CONSTANT Slice1BColours     \ B-slice colours
  131.  
  132.  
  133.  \ The middle slice is a scrolling play area and has two 8 colour playfields
  134.  \
  135.  \ A-slice = foreground playfield and B-slice = background playfield
  136.  \
  137.  \ Both these slices have extra-wide horizontal raster size to allow for
  138.  \ horizontal scrolling (1280 pixels), and an additional 320 pixels for
  139.  \ horizontal smooth wrapping.
  140.  \
  141.  \ These slices both also have 16 pixel extra border areas to allow
  142.  \ rendering of partially off-screen BOBs, since this would normally be
  143.  \ a main game play area.
  144.  \
  145.  
  146.   320                      CONSTANT Slice2Width        \ Lores width
  147.   170                      CONSTANT Slice2Height       \ Middle slice height
  148.   170 32 +                 CONSTANT Slice2RasterHeight \ Middle bitplane height
  149.   WORDINCLUDE
  150.   V_DUALPF                 CONSTANT Slice2Mode         \ Middle screenmode
  151.   LONGINCLUDE
  152.  
  153.   1280 320 + 32 +          CONSTANT Slice2ARasterWidth \ A-slice scroll-raster
  154.   3                        CONSTANT Slice2APlanes      \ A-slice planes
  155.   2 Slice2APlanes 1- LSL   CONSTANT Slice2AColours     \ A-slice colours
  156.  
  157.   640 320 + 32 +           CONSTANT Slice2BRasterWidth \ B-slice scroll-raster
  158.   3                        CONSTANT Slice2BPlanes      \ B-slice planes
  159.   2 Slice2BPlanes 1- LSL   CONSTANT Slice2BColours     \ B-slice colours
  160.  
  161.  \ The bottom slice is an ordinary single playfield with 32 colours
  162.  
  163.   640                      CONSTANT Slice3Width        \ Hires width
  164.   640                      CONSTANT Slice3RasterWidth  \ Raster=screenwidth
  165.  
  166.   DisplayHeight
  167.   Slice1Height -
  168.   Slice2Height -           CONSTANT Slice3Height       \ Bottom slice height
  169.  
  170.   4                        CONSTANT Slice3Planes       \ Bottom slice planes
  171.   2 Slice3Planes 1- LSL    CONSTANT Slice3Colours      \ Bottom slice colours
  172.   WORDINCLUDE
  173.   V_HIRES                  CONSTANT Slice3Mode         \ Bottom slice screenmode
  174.   LONGINCLUDE
  175.  
  176.   \ ***********************
  177.   \ Error handling routines
  178.   \ ***********************
  179.  
  180.   \ This error handler allows all errors to be routed via a comprehensive
  181.   \ sequential closedown routine, which is associated with the HeliOS
  182.   \ system error handler word ERROR".
  183.   \
  184.   \ When ERROR" senses an error, it prints an associated error message
  185.   \ delimited by '"' characters, and then closes everything down using the
  186.   \ routine CLOSEDOWN below which you have supplied.
  187.   \
  188.   \ This simplifies errors checks to the use of a single word, ERROR", which
  189.   \ displays a text message and closes eveything down.
  190.   \
  191.  
  192.   0 VARIABLE (CLOSEDOWN)
  193.  
  194.   : ?CLOSEDOWNERROR
  195.  
  196.   IF
  197.     CR
  198.     CR
  199.     TYPE
  200.     CR
  201.     CR
  202.     ." Press <Space> to quit!"
  203.     CR
  204.     CR
  205.     WAITSPACE
  206.     (CLOSEDOWN) @EXECUTE
  207.     QUIT
  208.   ELSE
  209.     DDROP
  210.   THEN
  211.   ;
  212.  
  213.   LATESTCFA VARIABLE ERROR1
  214.  
  215.   \ ********************************
  216.   \ Create pointer storage variables
  217.   \ ********************************
  218.  
  219.   \ Here we create a set of "pointers", initially set to a "null" value.
  220.   \
  221.   \ These "pointers" are set up as "long addresses" when various components
  222.   \ of the display system are allocated and initialised.
  223.   \
  224.   \ Note that initially these are all set to zero, and we clear them back
  225.   \ to zero when we de-allocate the associated resource.
  226.   \
  227.   \ These DPOINTERs are all initially set to "null" by using '0.'.
  228.   \
  229.   \ When we allocate memory or Amiga system resources in the program at
  230.   \ run-time, these pointers are updated to contain the 32-bit address
  231.   \ of the newly allocated resource.
  232.   \
  233.   \ Subsequently the symbolic DPOINTER name can be used in your code to
  234.   \ represent the associated address.
  235.  
  236.   0. DPOINTER Display1             \ Main Display structure pointer
  237.   0. DPOINTER Slice1               \ Slice 1 Slice structure pointer
  238.   0. DPOINTER Slice2               \ Slice 2 Slice structure pointer
  239.   0. DPOINTER Slice3               \ Slice 3 Slice structure pointer
  240.  
  241.   0. DPOINTER Slice1_ColorMap      \ Slice 1 ColourMap structure pointer
  242.   0. DPOINTER Slice2_ColorMap      \ Slice 2 ColourMap structure pointer
  243.   0. DPOINTER Slice3_ColorMap      \ Slice 3 ColourMap structure pointer
  244.  
  245.   0. DPOINTER Slice1A_RasInfo      \ Slice 1A RasInfo structure pointer
  246.   0. DPOINTER Slice1B_RasInfo      \ Slice 1B RasInfo structure pointer
  247.   0. DPOINTER Slice2A_RasInfo      \ Slice 2A RasInfo structure pointer
  248.   0. DPOINTER Slice2B_RasInfo      \ Slice 2B RasInfo structure pointer
  249.   0. DPOINTER Slice3_RasInfo       \ Slice 3  RasInfo structure pointer
  250.  
  251.   0. DPOINTER Slice1A_BMap         \ Slice 1A BitMap structure pointer
  252.   0. DPOINTER Slice1B_BMap         \ Slice 1B BitMap structure pointer
  253.   0. DPOINTER Slice2A_BMap         \ Slice 2A BitMap structure pointer
  254.   0. DPOINTER Slice2B_BMap         \ Slice 2B BitMap structure pointer
  255.   0. DPOINTER Slice3_BMap          \ Slice 3  BitMap structure pointer
  256.  
  257.   0. DPOINTER Slice1A_SliceControl \ Slice 1A SliceControl structure pointer
  258.   0. DPOINTER Slice1B_SliceControl \ Slice 1B SliceControl structure pointer
  259.   0. DPOINTER Slice2A_SliceControl \ Slice 2A SliceControl structure pointer
  260.   0. DPOINTER Slice2B_SliceControl \ Slice 2B SliceControl structure pointer
  261.  
  262.   \ *************
  263.   \ Colour tables
  264.   \ *************
  265.  
  266.   \ Each colour entry requies 2 bytes of storage space
  267.  
  268.   CREATEL Slice1_ColorTable        \ Create longword pointer
  269.   Slice1AColours 2* ALLOT          \ Allocate Slice1A colours * 2 bytes
  270.   Slice1BColours 2* ALLOT          \ Allocate Slice1B colours * 2 bytes
  271.  
  272.   CREATEL Slice2_ColorTable        \ Create longword pointer
  273.   Slice2AColours 2* ALLOT          \ Allocate Slice2A colours * 2 bytes
  274.   Slice2BColours 2* ALLOT          \ Allocate Slice2B colours * 2 bytes
  275.  
  276.   CREATEL Slice3_ColorTable  Slice3Colours  2* ALLOT
  277.  
  278.  
  279.   \ ***************************
  280.   \ Synchronised display scroll
  281.   \ ***************************
  282.  
  283.   \ This word is plugged into the interrupt driven SliceControl handler,
  284.   \ so will always execute automatically every frame with perfect timing.
  285.  
  286.   : MoveDisplay
  287.  
  288.   DDROP                                           \ Drop SliceControl pointer
  289.  
  290.   1 0  Slice1A_SliceControl  SETFIELD2SCROLL      \ Set 1 pixel H-scroll
  291.  
  292.   RAWKEY @ 79 =
  293.   IF
  294.     QUALIFIER @ 8 AND                             \ Is <Ctrl> pressed?
  295.     IF
  296.       12
  297.     ELSE
  298.       4
  299.     THEN
  300.     DUP
  301.        0  Slice2A_SliceControl  SETFIELD1SCROLL   \ Set foreground H-scroll
  302.     2/ 0  Slice2A_SliceControl  SETFIELD2SCROLL   \ Set background H-scroll
  303.   ELSE
  304.     RAWKEY @ 78 =
  305.     IF
  306.     QUALIFIER @ 8 AND                             \ Is <Ctrl> pressed?
  307.     IF
  308.       -12
  309.     ELSE
  310.       -4
  311.     THEN
  312.     DUP
  313.        0  Slice2A_SliceControl  SETFIELD1SCROLL \ Set foreground H-scroll
  314.     2/ 0  Slice2A_SliceControl  SETFIELD2SCROLL \ Set background H-scroll
  315.     THEN
  316.   THEN
  317.   ;
  318.  
  319.   LATESTCFA VARIABLE (MoveDisplay)                \ Store cfa address
  320.  
  321.   \ *************************************
  322.   \ Copper strip for graduated background
  323.   \ *************************************
  324.  
  325.   0. DVARIABLE Copper
  326.   0. DVARIABLE CopperLength
  327.  
  328.   : AddCopper
  329.  
  330.   Display1
  331.   Copper D@
  332.   ADDCOPPERSTRIP
  333.   SORTSTRIPTABLE
  334.   LINKSTRIPS
  335.   DDROP
  336.   ;
  337.  
  338.   : RemCopper                      \ Remove custom copper list from display
  339.  
  340.   Display1                         \ We are removing CopperList from Display1
  341.   Copper D@
  342.   DFLAG
  343.   IF
  344.     REMCOPPERSTRIP
  345.     LINKSTRIPS
  346.     DDROP
  347.   ELSE
  348.     DDDROP
  349.   THEN
  350.   ;
  351.  
  352.   : Create_Copper
  353.  
  354.   COPPERSTART
  355.   Copper D!
  356.   0 [ DECIMAL ] 190 [ HEX ] FFFE COPPERWAIT  DROP   0100 192 COPPERMOVE  DROP
  357.   0 [ DECIMAL ] 194 [ HEX ] FFFE COPPERWAIT  DROP   0200 192 COPPERMOVE  DROP
  358.   0 [ DECIMAL ] 198 [ HEX ] FFFE COPPERWAIT  DROP   0300 192 COPPERMOVE  DROP
  359.   0 [ DECIMAL ] 202 [ HEX ] FFFE COPPERWAIT  DROP   0400 192 COPPERMOVE  DROP
  360.   0 [ DECIMAL ] 204 [ HEX ] FFFE COPPERWAIT  DROP   0500 192 COPPERMOVE  DROP
  361.   0 [ DECIMAL ] 208 [ HEX ] FFFE COPPERWAIT  DROP   0600 192 COPPERMOVE  DROP
  362.   0 [ DECIMAL ] 212 [ HEX ] FFFE COPPERWAIT  DROP   0700 192 COPPERMOVE  DROP
  363.   0 [ DECIMAL ] 216 [ HEX ] FFFE COPPERWAIT  DROP   0800 192 COPPERMOVE  DROP
  364.   0 [ DECIMAL ] 220 [ HEX ] FFFE COPPERWAIT  DROP   0900 192 COPPERMOVE  DROP
  365.   0 [ DECIMAL ] 224 [ HEX ] FFFE COPPERWAIT  DROP   0A00 192 COPPERMOVE  DROP
  366.   0 [ DECIMAL ] 228 [ HEX ] FFFE COPPERWAIT  DROP   0B00 192 COPPERMOVE  DROP
  367.   0 [ DECIMAL ] 232 [ HEX ] FFFE COPPERWAIT  DROP   0C00 192 COPPERMOVE  DROP
  368.   0 [ DECIMAL ] 236 [ HEX ] FFFE COPPERWAIT  DROP   0D00 192 COPPERMOVE  DROP
  369.   0 [ DECIMAL ] 240 [ HEX ] FFFE COPPERWAIT  DROP   0E00 192 COPPERMOVE  DROP
  370.   0 [ DECIMAL ] 244 [ HEX ] FFFE COPPERWAIT  DROP   0F00 192 COPPERMOVE  DROP
  371.   [ DECIMAL ]
  372.   COPPEREND
  373.   CopperLength D!   Copper D!
  374.   ADDCOPPER
  375.   ;
  376.  
  377.   : Free_Copper
  378.  
  379.   RemCopper
  380.   Copper D@ FREEMEMORY
  381.   ;
  382.  
  383.   \ ***********************************
  384.   \ Create Display and Slice structures
  385.   \ ***********************************
  386.  
  387.   \ This routine simple makes blank structures, which then need to be
  388.   \ initialised in the CREATE_DISPLAY routine below.
  389.  
  390.   : CREATE_DSLICES
  391.  
  392.   DS_SIZEOF MAKESTRUCTURE Display1 MAKEPOINTER  \ Main "Display" structure
  393.  
  394.   SL_SIZEOF MAKESTRUCTURE Slice1   MAKEPOINTER  \ Top    "Slice" structure
  395.   SL_SIZEOF MAKESTRUCTURE Slice2   MAKEPOINTER  \ Middle "Slice" structure
  396.   SL_SIZEOF MAKESTRUCTURE Slice3   MAKEPOINTER  \ Bottom "Slice" structure
  397.   ;
  398.  
  399.   : FREE_DSLICES
  400.  
  401.   Slice3    DDUP FREEMEMORY   CLEARPOINTER
  402.   Slice2    DDUP FREEMEMORY   CLEARPOINTER
  403.   Slice1    DDUP FREEMEMORY   CLEARPOINTER
  404.   Display1  DDUP FREEMEMORY   CLEARPOINTER
  405.   ;
  406.  
  407.   \ ******************************
  408.   \ Create RasInfo structures etc.
  409.   \ ******************************
  410.  
  411.   : CREATE_RASINFO
  412.  
  413.   \ First allocate and initialise complete RasInfo structures.
  414.   \
  415.   \ This routine automatically allocates all BitMaps etc.
  416.   \
  417.  
  418.   Slice1ARasterWidth Slice1RasterHeight  Slice1APlanes   OPENRASINFO
  419.   DFLAG0= ERROR" Fail: RasInfo1A"
  420.   Slice1A_RasInfo MAKEPOINTER
  421.  
  422.   Slice1BRasterWidth Slice1RasterHeight  Slice1BPlanes   OPENRASINFO
  423.   DFLAG0= ERROR" Fail: RasInfo1B"
  424.   Slice1B_RasInfo MAKEPOINTER
  425.  
  426.   Slice2ARasterWidth Slice2RasterHeight Slice2APlanes    OPENRASINFO
  427.   DFLAG0= ERROR" Fail: RasInfo2A"
  428.   Slice2A_RasInfo MAKEPOINTER
  429.  
  430.   Slice2BRasterWidth Slice2RasterHeight Slice2BPlanes    OPENRASINFO
  431.   DFLAG0= ERROR" Fail: RasInfo2B"
  432.   Slice2B_RasInfo MAKEPOINTER
  433.  
  434.   Slice3RasterWidth  Slice3Height  Slice3Planes          OPENRASINFO
  435.   DFLAG0= ERROR" Fail: RasInfo3"
  436.   Slice3_RasInfo MAKEPOINTER
  437.  
  438.   \ Set invisible area "sprite margins" for middle slice RasInfo
  439.  
  440.   16              Slice2A_RasInfo         ri_RxOffset    INDEX!L
  441.   16              Slice2A_RasInfo         ri_RyOffset    INDEX!L
  442.  
  443.   16              Slice2B_RasInfo         ri_RxOffset    INDEX!L
  444.   16              Slice2B_RasInfo         ri_RyOffset    INDEX!L
  445.  
  446.   \ Link Dual Playfield RasInfo structures
  447.  
  448.   Slice1B_RasInfo Slice1A_RasInfo         ri_Next        INDEXD!L
  449.   Slice2B_RasInfo Slice2A_RasInfo         ri_Next        INDEXD!L
  450.  
  451.   \ Store BitMap pointers - often useful for later reference
  452.  
  453.   Slice1A_RasInfo  ri_BitMap INDEXD@L Slice1A_BMap MAKEPOINTER
  454.  
  455.   Slice1B_RasInfo  ri_BitMap INDEXD@L Slice1B_BMap MAKEPOINTER
  456.  
  457.   Slice2A_RasInfo  ri_BitMap INDEXD@L Slice2A_BMap MAKEPOINTER
  458.  
  459.   Slice2B_RasInfo  ri_BitMap INDEXD@L Slice2B_BMap MAKEPOINTER
  460.  
  461.   Slice3_RasInfo   ri_BitMap INDEXD@L Slice3_BMap  MAKEPOINTER
  462.   ;
  463.  
  464.   : FREE_RASINFO
  465.  
  466.   Slice3_RasInfo    DDUP CLOSERASINFO   CLEARPOINTER
  467.   Slice2B_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  468.   Slice2A_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  469.   Slice1B_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  470.   Slice1A_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  471.   ;
  472.  
  473.   \ ************************
  474.   \ Create Slice Copperlists
  475.   \ ************************
  476.  
  477.   \ This function builds the main display copperlist by:
  478.   \
  479.   \ 1. Initialising the individual Slice data structures
  480.   \ 2. Calling MAKECOPSTRIP for each slice, to build Slice copperlists
  481.   \ 3. Calling MAKEDISPLAY to build the master Display copperlist
  482.   \
  483.  
  484.   : CREATE_DISPLAY
  485.  
  486.   \ First initialise main display structures
  487.  
  488.   Slice1                           Display1  DS_Slice     INDEXD!L
  489.  
  490.   Slice2                           Slice1    SL_Next      INDEXD!L
  491.   Slice1Width                      Slice1    SL_DWidth    INDEX!L
  492.   Slice1Height                     Slice1    SL_DHeight   INDEX!L
  493.   DisplayTopLine                   Slice1    SL_DyOffset  INDEX!L
  494.   Slice1A_RasInfo                  Slice1    SL_RasInfo   INDEXD!L
  495.   Slice1_ColorMap                  Slice1    SL_ColorMap  INDEXD!L
  496.   Slice1Mode                       Slice1    SL_Modes     INDEX!L
  497.  
  498.   Slice3                           Slice2    SL_Next      INDEXD!L
  499.   Slice2Width                      Slice2    SL_DWidth    INDEX!L
  500.   Slice2Height                     Slice2    SL_DHeight   INDEX!L
  501.   Slice1Height DisplayTopLine + 1+ Slice2    SL_DyOffset  INDEX!L
  502.   Slice2A_RasInfo                  Slice2    SL_RasInfo   INDEXD!L
  503.   Slice2_ColorMap                  Slice2    SL_ColorMap  INDEXD!L
  504.   Slice2Mode                       Slice2    SL_Modes     INDEX!L
  505.  
  506.   Slice3Width                      Slice3    SL_DWidth    INDEX!L
  507.   Slice3Height                     Slice3    SL_DHeight   INDEX!L
  508.  
  509.   Slice1Height Slice2Height +
  510.   DisplayTopLine + 2+              Slice3    SL_DyOffset  INDEX!L
  511.  
  512.   Slice3_RasInfo                   Slice3    SL_RasInfo   INDEXD!L
  513.   Slice3_ColorMap                  Slice3    SL_ColorMap  INDEXD!L
  514.   Slice3Mode                       Slice3    SL_Modes     INDEX!L
  515.  
  516.   \ Generate copper list information for each of the display slices
  517.  
  518.   Slice1 MAKECOPSTRIP
  519.   D0= ERROR" Fail: Slice1CopStrip"
  520.   Slice2 MAKECOPSTRIP
  521.   D0= ERROR" Fail: Slice2CopStrip"
  522.   Slice3 MAKECOPSTRIP
  523.   D0= ERROR" Fail: Slice3CopStrip"
  524.  
  525.   \ Make display
  526.  
  527.   Display1 MAKEDISPLAY
  528.   D0= ERROR" Fail: Display1"
  529.   ;
  530.  
  531.   : FREE_DISPLAY
  532.  
  533.   Display1                 FREEDISPLAY
  534.   Slice3                   FREECOPSTRIP
  535.   Slice2                   FREECOPSTRIP
  536.   Slice1                   FREECOPSTRIP
  537.   ;
  538.  
  539.   \ ***************************************************
  540.   \ Create SliceControl structures for scrolling slices
  541.   \ ***************************************************
  542.  
  543.   \ SliceControl structures are used to control any slices which perform
  544.   \ mapping or scrolling functions, or which require double or triple
  545.   \ playfield buffering.
  546.   \
  547.   \ In this case we have two slices which scroll horizontally, each with
  548.   \ automatic wrap.
  549.   \
  550.   \ The front middle slice playfield in this case is double buffered to
  551.   \ allow smooth BOB rendering as a game main playfield.
  552.   \
  553.   \ The HeliOS SLICECONTROL functions are extremely powerful, since they
  554.   \ handle all the double buffering and scrolling with automatic wrap.
  555.   \
  556.  
  557.   : CREATE_SLICECONTROLS
  558.  
  559.   \ Make two top Dual-Playfield SliceControls, each playfield with standard
  560.   \ single buffered bitmap displays, as indicated by "-1" parameters
  561.  
  562.   Slice1  -1 -1 -1 -1 MAKEDPSLICECONTROL
  563.   DFLAG0= ERROR" Fail: SliceControl1"
  564.   Slice1A_SliceControl MAKEPOINTER
  565.  
  566.   \ Get second dual playfield SliceControl pointer
  567.  
  568.   Slice1A_SliceControl SliceControl_DPSControl2 INDEXD@L
  569.   Slice1B_SliceControl MAKEPOINTER
  570.  
  571.   \ Set BPLCON2 control value
  572.  
  573.   [ BIN ] 100100 [ DECIMAL ]
  574.   Slice1A_SliceControl    SliceControl_BPLCON2     INDEX!L
  575.  
  576.   \ Set up rear playfield for automatic horizontal smooth wrapping
  577.  
  578.   1 Slice1B_SliceControl  SliceControl_HWrapFlag   INDEX!L
  579.  
  580.   \ Make middle two Dual-Playfield SliceControls, the rear playfield with
  581.   \ a standard single buffered bitmap display, configured by "-1" parameters,
  582.   \ and the front one with a double buffered display, configured by the 0
  583.   \ parameters.
  584.  
  585.   Slice2  0  0 -1 -1 MAKEDPSLICECONTROL
  586.   DFLAG0= ERROR" Fail: SliceControl2"
  587.   Slice2A_SliceControl MAKEPOINTER
  588.  
  589.   \ Get second dual playfield slice control
  590.  
  591.   Slice2A_SliceControl    SliceControl_DPSControl2 INDEXD@L
  592.   Slice2B_SliceControl MAKEPOINTER
  593.  
  594.   \ Set BPLCON2 control value
  595.  
  596.   [ BIN ] 100100 [ DECIMAL ]
  597.   Slice2A_SliceControl    SliceControl_BPLCON2     INDEX!L
  598.  
  599.   \ Set up both playfields for automatic horizontal smooth wrapping
  600.  
  601.   1 Slice2A_SliceControl  SliceControl_HWrapFlag   INDEX!L
  602.   1 Slice2B_SliceControl  SliceControl_HWrapFlag   INDEX!L
  603.  
  604.   \ Install display movement control word
  605.  
  606.   (MoveDisplay) @ Slice2A_SliceControl SliceControl_BeforeForth INDEX!L
  607.  
  608.   \ Install slice controls into HeliOS display control system
  609.  
  610.   Slice1A_SliceControl  INSTALLSLICECONTROL
  611.   Slice1B_SliceControl  INSTALLSLICECONTROL
  612.   Slice2A_SliceControl  INSTALLSLICECONTROL
  613.   Slice2B_SliceControl  INSTALLSLICECONTROL
  614.   ;
  615.  
  616.   : FREE_SLICECONTROLS
  617.  
  618.   CLEARSLICECONTROLS
  619.   Slice2B_SliceControl  CLOSESLICECONTROL
  620.   Slice2A_SliceControl  CLOSESLICECONTROL
  621.   Slice1B_SliceControl  CLOSESLICECONTROL
  622.   Slice1A_SliceControl  CLOSESLICECONTROL
  623.   ;
  624.  
  625.   \ These routines load IFF pictures into supplied BitMaps, and correctly
  626.   \ initialise the supplied ColorTables.
  627.   \
  628.   \ The ColorTables are then used to create initialised ColorMap structures.
  629.   \
  630.  
  631.   : CREATE_IMAGERY
  632.  
  633.   Slice1A_BMap
  634.   Slice1_ColorTable
  635.   Slice1APic
  636.   10
  637.   2 DOSLIB
  638.   10 <> ERROR" Fail: Slice1APic"
  639.  
  640.   Slice1B_BMap
  641.   Slice1_ColorTable Slice1AColours 2 M* D+
  642.   Slice1BPic
  643.   10
  644.   2 DOSLIB
  645.   10 <> ERROR" Fail: Slice1BPic"
  646.  
  647.   Slice2A_BMap
  648.   Slice2_ColorTable
  649.   Slice2APic
  650.   10
  651.   2 DOSLIB
  652.   10 <> ERROR" Fail: Slice2APic"
  653.  
  654.   Slice2B_BMap
  655.   Slice2_ColorTable Slice2AColours 2 M* D+
  656.   Slice2BPic
  657.   10
  658.   2 DOSLIB
  659.   10 <> ERROR" Fail: Slice2BPic"
  660.  
  661.   Slice3_BMap
  662.   Slice3_ColorTable
  663.   Slice3Pic
  664.   10
  665.   2 DOSLIB
  666.   10 <> ERROR" Fail: Slice3Pic"
  667.  
  668.   Slice1_ColorTable  Slice1AColours Slice1BColours + MAKECOLORMAP
  669.   DFLAG0= ERROR" Fail: Slice1ColorMap"
  670.   Slice1_ColorMap MAKEPOINTER
  671.  
  672.   Slice2_ColorTable  Slice2AColours Slice2BColours + MAKECOLORMAP
  673.   DFLAG0= ERROR" Fail: Slice2ColorMap"
  674.   Slice2_ColorMap MAKEPOINTER
  675.  
  676.   Slice3_ColorTable   Slice3Colours                  MAKECOLORMAP
  677.   DFLAG0= ERROR" Fail: Slice3ColorMap"
  678.   Slice3_ColorMap MAKEPOINTER
  679.   ;
  680.  
  681.   : FREE_IMAGERY
  682.  
  683.   Slice3_ColorMap  DDUP FREECOLORMAP  CLEARPOINTER
  684.   Slice2_ColorMap  DDUP FREECOLORMAP  CLEARPOINTER
  685.   Slice1_ColorMap  DDUP FREECOLORMAP  CLEARPOINTER
  686.   ;
  687.  
  688.   \ *********************
  689.   \ Close down everything
  690.   \ *********************
  691.  
  692.   : CLOSEDOWN
  693.  
  694.   FREE_COPPER
  695.   FREE_SLICECONTROLS
  696.   FREE_DISPLAY
  697.   FREE_IMAGERY
  698.   FREE_RASINFO
  699.   FREE_DSLICES
  700.   RESETERROR"
  701.   ;
  702.  
  703.   LATESTCFA (CLOSEDOWN) !
  704.  
  705.   : TestDisplay
  706.  
  707.   SCRCLR
  708.   CR
  709.  
  710.   ."        **********************************************************"
  711.   CR 6 FPENSET
  712.   ."             PARALLAX SCROLLING DUAL PLAYFIELD WITH TEXT DEMO"
  713.   CR 1 FPENSET
  714.   ."        **********************************************************"
  715.   CR
  716.   CR
  717.   ."        This code demonstrates how to create a display with multiple"
  718.   CR
  719.   ."        dual playfield slices and variable speed parallax scrolling."
  720.   CR
  721.   CR
  722.   ."        This code builds upon the following Demos:"
  723.   CR
  724.   CR
  725.   ."        Demo1_SinglePF.src"
  726.   CR
  727.   ."        Demo2_SinglePFCopper.src"
  728.   CR
  729.   CR
  730.   ."        **********************************************************"
  731.   CR 6 FPENSET
  732.   ."                  Press <Space> or <L-Mouse> to see Demo"
  733.   CR 3 FPENSET
  734.   ."            Use keyboard to change scroll speed and direction."
  735.   CR
  736.   ."        **********************************************************"
  737.   CR
  738.  
  739.   WAITSPACE
  740.  
  741.   SCRCLR
  742.  
  743.  
  744.   ERROR1 SETERROR"
  745.  
  746.   CREATE_DSLICES
  747.   CREATE_RASINFO
  748.   CREATE_IMAGERY
  749.   CREATE_DISPLAY
  750.   CREATE_SLICECONTROLS
  751.   CREATE_COPPER
  752.  
  753.   HeliOS_On
  754.  
  755.   1 FrameRate !L
  756.  
  757.   Display1 SHOWDISPLAY
  758.  
  759.   1 0  Slice1A_SliceControl  SETFIELD2SCROLL   \ Set 1 pixel H-scroll
  760.   4 0  Slice2A_SliceControl  SETFIELD1SCROLL   \ Set foreground H-scroll
  761.   2 0  Slice2A_SliceControl  SETFIELD2SCROLL   \ Set background H-scroll
  762.  
  763.   WAITSPACE
  764.  
  765.   HeliOS_Off
  766.  
  767.   CLOSEDOWN
  768.   ;
  769.  
  770.   TestDisplay
  771.